﻿using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

namespace MiHoMiao.Mono.UGUI.Triggers
{
    /// <summary>
    ///     鼠标点击的触发器
    /// </summary>
    public class TriggerClicking : UIBehaviour, ITrigger, IPointerClickHandler
    {
        [SerializeField] private UnityEvent m_OnTrigger = new UnityEvent();

        public void OnPointerClick(PointerEventData eventData)
        {
            if (eventData.button != PointerEventData.InputButton.Left) return;
            if (!IsActive()) return;
            m_OnTrigger.Invoke();
        }

        public UnityEvent OnTrigger
        {
            get => m_OnTrigger;
            set => m_OnTrigger = value;
        }
    }
}